{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Imports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import quiz_tests"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Quiz Solution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def calculate_arithmetic_rate_of_return(close):\n",
    "    \"\"\"\n",
    "    Compute returns for each ticker and date in close.\n",
    "    \n",
    "    Parameters\n",
    "    ----------\n",
    "    close : DataFrame\n",
    "        Close prices for each ticker and date\n",
    "    \n",
    "    Returns\n",
    "    -------\n",
    "    arithmnetic_returns : Series\n",
    "        arithmnetic_returns at the end of the period for each ticker\n",
    "        \n",
    "    \"\"\"\n",
    "    # TODO: Implement Function\n",
    "    \n",
    "    returns = close / close.shift(1) - 1\n",
    "    arithmetic_returns = returns.cumsum(axis =0).iloc[returns.shape[0]-1]/returns.shape[0]\n",
    "    \n",
    "    return arithmetic_returns\n",
    "\n",
    "\n",
    "quiz_tests.test_calculate_arithmetic_rate_of_return(calculate_arithmetic_rate_of_return)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
